package com.link2room.ironhide.service.impl;

import com.link2room.common.service.ICommonService;
import com.link2room.ironhide.entity.L2RHotelRmtypePicture;
import com.link2room.ironhide.entity.L2RHotelRoomtype;
import com.link2room.ironhide.service.IHotelRmtypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by sss on 2016/11/11.
 */
@Service("hotelRmtypeService")
public class HotelRmtypeServiceImpl implements IHotelRmtypeService {
    @Resource
    private ICommonService commonService;

    @Override
    @Transactional
    public void saveOrUpdateHotelRmtype(L2RHotelRoomtype l2RHotelRoomtype, L2RHotelRmtypePicture bigPic, List<L2RHotelRmtypePicture> hotelRmtypePictureList)throws Exception{
        commonService.saveOrUpdate(l2RHotelRoomtype);
        L2RHotelRmtypePicture queryL2RHR=new L2RHotelRmtypePicture();
        queryL2RHR.setLhotelGroupCode(l2RHotelRoomtype.getLhotelGroupCode());
        queryL2RHR.setLhotelCode(l2RHotelRoomtype.getLhotelCode());
        queryL2RHR.setRmtype(l2RHotelRoomtype.getRmtype());
        commonService.deleteAllEQ(L2RHotelRmtypePicture.class,queryL2RHR);
        if(bigPic!=null){
            commonService.saveOrUpdate(bigPic);
        }
        if(hotelRmtypePictureList!=null){
            commonService.saveOrUpdateList(hotelRmtypePictureList);
        }
    }
}
